package com.example.houselease.controller;

import com.example.houselease.pojo.dto.admin.AdminAddNewDTO;
import com.example.houselease.pojo.dto.admin.AdminLoginDTO;
import com.example.houselease.pojo.dto.admin.PictureAddNewDTO;
import com.example.houselease.service.IPictureService;
import com.example.houselease.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Slf4j
@Api(tags = "3. 图片管理模块")
@RequestMapping("/pictures")
public class PictureController {
    @Autowired
    private IPictureService iPictureService;


    @PostMapping("/add-new")
    @ApiOperation("添加图片")
    @ApiOperationSupport(order = 100)
    @PreAuthorize("hasAnyAuthority('house/picture/add-new')")
    JsonResult<Void> add(@Valid PictureAddNewDTO pictureAddNewDTO){
        log.debug("开始处理【添加图片】请求，参数：{}",pictureAddNewDTO);
        iPictureService.addNew(pictureAddNewDTO);
        return JsonResult.ok();
    }
}
